﻿using System.Collections.Generic;
using System.Linq;
using Beaker.FileSystem;
using Beaker.Specs;
using OpenCube.IO.Overload;

namespace OpenCube.IO.Specs.Builders
{
	internal sealed class OverloadingFileSystemBuilder
		: Builder<OverloadingFileSystem>
	{
		private readonly IList<IFolder> _folders = new List<IFolder>();

		public OverloadingFileSystemBuilder AddFolder(IFolder folder)
		{
			_folders.Add(folder);
			return this;
		}

		public OverloadingFileSystemBuilder AddFallbackFolders(params IFolder[] folders)
		{
			if (folders != null)
			{
				foreach (IFolder folder in _folders)
					_folders.Add(folder);
			}

			return this;
		}

		public override OverloadingFileSystem Build()
		{
			List<IFolder> folders = _folders.ToList();
			return new OverloadingFileSystem(folders);
		}
	}
}